package com.zhengke.service.cggl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhengke.common.dao.CommonDao;
import com.zhengke.common.object.Result;
import com.zhengke.pojo.MemberStat;
import com.zhengke.pojo.SysDictionaryItem;
import com.zhengke.pojo.TvPurchaseDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * *******************************
 * 项目名称：tvmall-parent
 * 文件名称：CGGL030ServiceImpl
 * 类说明：  采购退货
 * 创建时间：2020/1/14 12:09
 *
 * @author 王东科
 * @version 1.0
 * *******************************
 */
@Service
public class CGGL030ServiceImpl implements CGGL030Service {

    @Autowired
    private CommonDao commonDao;
    @SuppressWarnings("unchecked")
    @Override
    public Result queryList(String goodsName, int pageNum, int size) throws Exception {
        PageHelper.startPage(pageNum, size, true);

        List<MemberStat> list = (List<MemberStat>) commonDao.findForList("PurchaseDetailsMapper.queryList", goodsName);
        PageInfo<MemberStat> pageInfo = new PageInfo<MemberStat>(list);
        Result rs = new Result();
        rs.setCode("0");
        rs.setCount(pageInfo.getTotal());
        rs.setData(list);
        return rs;
    }
    @SuppressWarnings("unchecked")
    @Override
    public List<SysDictionaryItem> queryListById(Integer dicId) throws Exception {

        List<SysDictionaryItem> list = (List<SysDictionaryItem>) commonDao.findForList("PurchaseDetailsMapper.querySdi", dicId);
        return list;
    }

    @Override
    public void updateGoodsDetail(TvPurchaseDetails tvPurchaseDetails) throws Exception {
        Integer i = (Integer)commonDao.update("PurchaseDetailsMapper.updateById",tvPurchaseDetails);
        if(i<0) {
            throw new Exception("修改失败");
        }
    }
}
